package com.justnow.offer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author justnow
 * Created on 2020-09-04
 * Description
 *
 * 给定一个由若干0和1组成的数组A，我们做多可以将k
 * 个值从0变成1，返回仅包含1的最长连续子数组的长度
 */
public class Bilibili01 {
    public int GetMaxConsecutiveOnes (int[] arr, int k) {
        // write code here
        int allMax = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 0)
                list.add(i);
        }
        int size = list.size();
        for (int i = 0; i < size - k; i++) {
            for (int j = i; j < k; j++) {
                
            }
        }

        return 0;
    }

    public int getMost(int[] arr) {
        int start = 0, end = 0, max = 0;
        int length = arr.length;
        while (end < length && start < length ) {
            while (start < length && arr[start] != 1 ) {
                start++;
            }
            if (start == length)
                return 0;
            end = start;
            while (end < length && arr[start] == 1) {
                end++;
            }
            start = end;
            max = Math.max(end - start, max);
        }
        return max;
    }
}
